package vista;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.border.LineBorder;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.SwingConstants;
import javax.swing.LayoutStyle.ComponentPlacement;

public class PanelInformacionAlumno extends JPanel {
	private JTextField textFieldNombre;
	private JTextField textFieldSegundoApellido;
	private JTextField textFieldPrimerApellido;
	private JTextField textFieldExpediente;
	private JLabel labelPrimerApellido,labelNombre,labelSegundoApellido,labelFoto,lblNExpediente;

	/**
	 * Create the panel.
	 */
	public PanelInformacionAlumno() {
		
		labelPrimerApellido = new JLabel("Primer Apellido");
		
		labelNombre = new JLabel("Nombre");
		
		textFieldNombre = new JTextField();
		textFieldNombre.setEditable(false);
		textFieldNombre.setColumns(10);
		
		textFieldSegundoApellido = new JTextField();
		textFieldSegundoApellido.setEditable(false);
		textFieldSegundoApellido.setColumns(10);
		
		labelSegundoApellido = new JLabel("Segundo Apellido");
		
		textFieldPrimerApellido = new JTextField();
		textFieldPrimerApellido.setEditable(false);
		textFieldPrimerApellido.setColumns(10);
		
		labelFoto = new JLabel();
		labelFoto.setHorizontalTextPosition(SwingConstants.CENTER);
		labelFoto.setHorizontalAlignment(SwingConstants.CENTER);
		labelFoto.setBorder(new LineBorder(new Color(0, 0, 0)));
		
		lblNExpediente = new JLabel("N\u00BA Expediente:");
		
		textFieldExpediente = new JTextField();
		textFieldExpediente.setEditable(false);
		
		textFieldExpediente.setColumns(10);
		GroupLayout groupLayout = new GroupLayout(this);
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap()
					.addComponent(labelFoto, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE)
					.addGap(18)
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addComponent(labelNombre)
						.addComponent(lblNExpediente)
						.addComponent(labelPrimerApellido)
						.addComponent(labelSegundoApellido))
					.addGap(56)
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addComponent(textFieldSegundoApellido, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(textFieldPrimerApellido, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(textFieldExpediente, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE))
							.addGroup(groupLayout.createSequentialGroup()
								.addComponent(textFieldNombre, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addPreferredGap(ComponentPlacement.RELATED))))
					.addGap(92))
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap()
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addGroup(groupLayout.createSequentialGroup()
							.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
								.addComponent(lblNExpediente)
								.addComponent(textFieldExpediente, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
							.addGap(18)
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addComponent(labelNombre)
								.addComponent(textFieldNombre, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
							.addGap(11)
							.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
								.addComponent(labelPrimerApellido)
								.addComponent(textFieldPrimerApellido, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
							.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
								.addGroup(groupLayout.createSequentialGroup()
									.addGap(18)
									.addComponent(labelSegundoApellido))
								.addGroup(groupLayout.createSequentialGroup()
									.addPreferredGap(ComponentPlacement.UNRELATED)
									.addComponent(textFieldSegundoApellido, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
						.addComponent(labelFoto, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE))
					.addContainerGap(22, Short.MAX_VALUE))
		);
		setLayout(groupLayout);

	}
	
	public void setNombre(String nombre){
		
		textFieldNombre.setText(nombre);
	}
	public void setPrimerApellido(String apellido){
		
		textFieldPrimerApellido.setText(apellido);
	}
	public void setSegundoApellido(String apellido){
	
		textFieldSegundoApellido.setText(apellido);
	}
	public void setImagenAlumno(ImageIcon imagen){
		
		ImageIcon IconoFoto = new ImageIcon(imagen.getImage().getScaledInstance(labelFoto.getWidth(), labelFoto.getHeight(), Image.SCALE_DEFAULT));
		labelFoto.setIcon(IconoFoto);
	}
	public void setNumExpediente(int expediente){
		
		textFieldExpediente.setText(""+expediente);
		
	}
	
}
